import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Param,
  Delete,
  UseGuards,
  SetMetadata,
  Query,
} from '@nestjs/common';
import { GuradService } from './gurad.service';
import { CreateGuradDto } from './dto/create-gurad.dto';
import { UpdateGuradDto } from './dto/update-gurad.dto';
import { GuradGuard } from './gurad.guard';
import { Role } from './role/role.decorator';
import { ApiTags } from '@nestjs/swagger';
@ApiTags('守卫')
// @UseGuards(GuradGuard)
@Controller('gurad')
export class GuradController {
  constructor(private readonly guradService: GuradService) {}

  @Post()
  create(@Body() createGuradDto: CreateGuradDto) {
    return this.guradService.create(createGuradDto);
  }

  @Get()
  // @SetMetadata('role', ['admin'])
  @Role(['admin'])
  findAll(@Query() name: string) {
    console.log(13);
    return this.guradService.findAll({ keyWord: name });
  }

  @Get(':id')
  findOne(@Param('id') id: string) {
    console.log(2222);
    return this.guradService.findOne(+id);
  }

  @Patch(':id')
  update(@Param('id') id: string, @Body() updateGuradDto: UpdateGuradDto) {
    return this.guradService.update(+id, updateGuradDto);
  }

  @Delete(':id')
  remove(@Param('id') id: string) {
    return this.guradService.remove(+id);
  }
}
